import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PurchaseTaskVO, PurchaseTaskForm, PurchaseTaskQuery } from '@/api/purchase/purchase/types';

/**
 * 查询采购任务列表
 * @param query
 * @returns {*}
 */

export const listPurchaseTask = (query?: PurchaseTaskQuery): AxiosPromise<PurchaseTaskVO[]> => {
  return request({
    url: '/oa/purchaseTask/pagelist',
    method: 'get',
    params: query
  });
};

/**
 * 查询采购任务详细
 * @param purchaseTaskId
 */
export const getPurchaseTask = (purchaseTaskId: string | number): AxiosPromise<PurchaseTaskVO> => {
  return request({
    url: '/oa/purchaseTask/' + purchaseTaskId,
    method: 'get'
  });
};

/**
 * 新增采购任务
 * @param data
 */
export const addPurchaseTask = (data: PurchaseTaskForm) => {
  return request({
    url: '/oa/purchaseTask/add',
    method: 'post',
    data: data
  });
};

/**
 * 修改采购任务
 * @param data
 */
export const updatePurchaseTask = (data: PurchaseTaskForm) => {
  return request({
    url: '/oa/purchaseTask/edit',
    method: 'put',
    data: data
  });
};

/**
 * 删除采购任务
 * @param purchaseTaskId
 */
export const delPurchaseTask = (purchaseTaskId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/purchaseTask/' + purchaseTaskId,
    method: 'delete'
  });
};
